import { TIMEOUT } from "./config";
import { BASE_URL } from "./config";

import axios from "axios";


class HY_Fetch{
    constructor(baseurl,timeout){
        this.instance = axios.create({
            baseURL:baseurl,
            timeout:timeout
        })
        this.instance.interceptors.response.use((res)=>{
            return res.data;
        })
    }
    request(config){
        return this.instance(config)
    }
    get(config){
        return this.instance({
            ...config,
            method:'get'
        })
    }
    post(config){
        return this.instance({
            ...config,
            method:'post'
        })
    }
}

export default new HY_Fetch(BASE_URL,TIMEOUT);